'use strict';

const { mysql } = require('./config.mysql');
const redis = require('./config.redis');

module.exports = appInfo => {
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1547565309265_2375';

  // add your config here
  config.middleware = [ 'authorization' ];
  // config.middleware = [];

  config.authWhiteList = [
    '/login',
    '/register',
    '/logout',
  ];

  config.auth_cookie_name = 'token';

  // token凭证
  config.jwtSecret = 'fish';

  config.passportLocal = {
    usernameField: 'username',
    passwordField: 'password',
  };

  // mysql数据库
  config.mysql = mysql;

  // redis
  config.redis = redis;

  // 跨域
  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
    // credentials: true,
    // origin: 'http://localhost:8084',
  };

  // post 安全关闭
  config.security = {
    csrf: false,
  };

  return config;
};
